const path = require('path')

module.exports = {
  chainWebpack: config => {
    const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
    types.forEach(type =>
      addStyleResource(config.module.rule('less').oneOf(type))
    )
  },

  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  // 打包时不生成.map文件
  baseUrl: 'ydj',
  outputDir: 'ydj',
  assetsDir: undefined,
  runtimeCompiler: undefined,
  productionSourceMap: false,
  parallel: undefined
}

function addStyleResource (rule) {
  rule
    .use('style-resource')
    .loader('style-resources-loader')
    .options({
      patterns: [
        path.resolve(__dirname, 'src/assets/styles/variable.less'),
        path.resolve(__dirname, 'src/assets/styles/mixin.less')
      ]
    })
}
